package com.maybach.workflow.core.test.mock;

import com.maybach.util.AssertUtil;
import com.maybach.workflow.common.api.WorkFlowContext;
import com.maybach.workflow.common.model.FlowTaskActorDO;
import com.maybach.workflow.core.service.SecurityService;

import java.util.List;

/**
 * Created by houenxun on 16/1/21.
 */
public class SecurityServiceMock  implements SecurityService{
    @Override
    public boolean isPermitted(WorkFlowContext context, FlowTaskActorDO taskActorDO) {
        System.out.println(taskActorDO);
        return true;
    }

    @Override
    public boolean isPermitted(WorkFlowContext context, List<FlowTaskActorDO> taskActorList) {
        AssertUtil.notNull(taskActorList, "taskActorList");
        for(FlowTaskActorDO taskActorDO : taskActorList){
            if(this.isPermitted(context, taskActorDO)){
                if(null != context) {
                    context.setTaskActor(taskActorDO);
                }
                return true;
            }
        }

        return false;
    }

    @Override
    public Long getUserId() {
        return 1L;
    }

    @Override
    public String getUserName() {
        return "展驰";
    }

    @Override
    public String getUserLable() {
        return "测试";
    }
}
